package android.slc.fast.vd.list;

import android.slc.fast.vd.wrapper.IBaseListPageWrapper;
import android.slc.adapter.LoadMoreDataFormat3;

import java.io.Serializable;
import java.util.List;


/**
 * 基础的分页加载盒子vm
 *
 * @author slc
 * @date 2020-08-25 16:13
 */
public abstract class BaseListPageVd<T extends Serializable, VS extends BaseListCommonVmSub<T>> extends BaseListCommonVd<T, VS>
        implements LoadMoreDataFormat3.LoadModelCallback {

    protected IBaseListPageWrapper<?> getListPageWrapper() {
        if (vmSub instanceof IBaseListPageWrapper<?>) {
            return (IBaseListPageWrapper<?>) vmSub;
        }
        throw new RuntimeException("vmBox没有实现IBaseListPageWrapper接口");
    }

    @Override
    protected void initView() {
        super.initView();
    }

    @Override
    protected void initMustCondition() {
        super.initMustCondition();
        getListPageWrapper().getLoadMoreDataFormat3().setLoadModelCallback(this);
    }

    @Override
    public void refresh(List<?> list) {
        setRefreshing(false);
    }

    @Override
    public void loadMoreEnd() {
        //什么也不做
    }

    @Override
    public void loadMoreComplete() {
        //什么也不做
    }

    @Override
    public void loadMoreFail() {
        //什么也不做
    }

    @Override
    public void setRefreshing(boolean refresh) {
        if(refresh){
            notifyRefreshing();
        }
    }

}
